﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Text;
using System.Security.Cryptography;
using System.Text.RegularExpressions;

namespace SilverlightDatabase
{
    public static class FileNameMaker
    {
        public static string Make<T>(string databaseName)
        {
            return Make(typeof(T), databaseName);
        }

        public static string Make(Type type, string databaseName)
        {
            var regex = new Regex(@"(?<extra>,[^\[\]]*)");
            var name = string.Concat(databaseName, ".", type.FullName);

            if (regex.IsMatch(name))
            {
                var match = regex.Match(name);
                var group = match.Groups["extra"];

                name = name.Remove(group.Index, group.Length);
            }

            return name;
        }
    }
}
